 <html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>JS实现滚动变色的文字效果</title> 
</head> 
<body> 
 
<script type="text/javascript">

	var message="请注意此段文字，部分文字染成红色，且红色循环移动";
	var baseColor="#333333";//默认文字颜色
	var selectColor="#ff0000";//选中变为红色
	if(document.all || document.getElementById){
	  document.write('<font color="'+baseColor+'">');
	  for(var i=0;i<message.length;i++){
	     document.write('<span id="light'+i+'">'+message.charAt(i)+'</sapn>');
	  }
	  document.write('</font>');
	}else{
		  document.write(message);
	}

   var index = 0;
   var flashCount=8;//闪亮的个数  
   function rolling(){
   	 if(index ==0){
        for(var i=0;i<message.length;i++){
           getObj(i).style.color=baseColor;
        }
   	 }
   	 getObj(index).style.color=selectColor; 
   	 if(index > flashCount-1){
           getObj(index-flashCount).style.color=baseColor;
   	 }
	 if (index < message.length-1){
	 	index++ 
	 }else{
	 	index=0;
	 }
   }

   function getObj(number){
      var obj =document.all? eval("document.all.light"+number) : document.getElementById("light"+number); 
      return obj 
   } 
   
   var flashing=setInterval("rolling()",100);
</script> 
</body> 
</html> 
